<template>
  <div>
    <!-- 导航栏 -->
    <div class="body">
      <div class="nav">
        <van-nav-bar title="新增收货地址" @click-left="onClickLeft" right-text left-text left-arrow />

        <!-- @click-right="onClickRight" -->
      </div>
      <van-address-edit
        :area-list="areaList"
        show-postal
        show-delete
        show-set-default
        show-search-result
        :search-result="searchResult"
        :area-columns-placeholder="['请选择', '请选择', '请选择']"
        @save="onSave"
        @delete="onDelete"
      />
    </div>
  </div>
</template>
<script>
import areaList from "@/assets/address.js";
export default {
  data() {
    return {
      areaList: areaList,
      searchResult: []
    };
  },

  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    onSave(content) {
      // console.log(content);
      let url = "/address/add";
      let data = content;
      this.$axios.post(url,data).then(res=>{
        // console.log('res',res);
        // this.$router.push('/address/list')
        this.$router.go(-1);
      }).catch(err=>{
        console.log('err',err);
        
      })
    },
    onDelete() {
      //   Toast('delete');
      this.$router.push("./address/list");
    },
  }
};
</script>

<style lang="less" scoped>
.body {
  height: 100vh;
  background: #f8f8f8;
  .nav {
    height: 56px;
    .van-nav-bar {
      height: 100%;
      line-height: 56px;
      .van-nav-bar__left {
        .van-icon {
          color: black;
        }
      }
    }
  }
}
.basics {
  height: 52px;
  line-height: 52px;
  margin-left: 15px;
  span {
    color: #afb7bc;
  }
}
</style>